<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <title>ajax联动</title>
    <script src="/Public/Common/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="/Public/Common/js/ajax-operate.js"></script>
</head>
<body>


<!--主页面-->

<form method="post" action=<?php echo U('Index/index');?>>
    <table>
        <tr>
            <th><em>*</em>所在城市</th>
            <td>
                <select id="province" name="province" class="select-ipt">
                    <option value="0">请选择</option>
                    <?php if(is_array($province)): $i = 0; $__LIST__ = $province;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$province): $mod = ($i % 2 );++$i;?><option value="<?php echo ($province['region_id']); ?>"><?php echo ($province['region_name']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                </select>
                <select name="city" id="city" class="select-ipt">
                    <option value="0">请选择</option>
                </select>
                <select name="area" id="area" class="select-ipt">
                    <option value="0">请选择</option>
                </select>
                <!--<span>机构所在城市</span>-->
            </td>
            <td>&nbsp;</td>
        </tr>
    </table>

</form>



<script type="text/javascript">


    //获取城市
    $('#province').change(function(){
        var _this = $(this);
        $.ajax({
            url:"<?php echo U('Index/getCity');?>",
            type:'post',
            data:{region_id:_this.val()},
            success:function(data){
                var html = '<option value="-1">请选择</option>';
                for(var i in data){
                    html +='<option value="'+data[i].region_id+'">'+data[i].region_name+'</option>';
                }
                $('#city').html(html);
            }
        });
    });
    //获取地区
    $('#city').change(function(){
        var _this = $(this);
        $.ajax({
            url:"<?php echo U('Index/getArea');?>",
            type:'post',
            data:{region_id:_this.val()},
            success:function(data){
                var html = '<option value="-1">请选择</option>';
                for(var i in data){
                    html +='<option value="'+data[i].region_id+'">'+data[i].region_name+'</option>';
                }
                $('#area').html(html);
            }
        });
    });


</script>

</body>